<!DOCTYPE html>
<html lang="en">
<head>
    <title>车险理赔--套餐审核</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/laypage.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/laypage/laypage.js" charset="utf-8"></script>
    <script src="/js/vue/vue.min.js"></script>
    <script src="/js/layer/layer.js" charset="utf-8"></script>
</head>
<body>
<script src="/js/webSocket.js"></script>
<section id="container">
<#include "sider.ftl">
    <section id="main-content">
        <section class="wrapper">
            <div class="table-agile-info">
                <div class="panel panel-default" id="app">
                    <div class="panel-heading">
                        保险套餐审核管理
                    </div>
                    <section class="panel">
                    <#--搜索框-->
                        <header class="panel-heading wht-bg">
                            <h4 class="gen-case">
                                <form action="#" class="pull-right mail-src-position">
                                    <div class="input-append">
                                        <input type="text" class="form-control search" placeholder="请输入套餐名称"
                                               id="keyword" name="keyword">
                                    </div>
                                </form>
                            </h4>
                        </header>
                        <div class="panel-body minimal">
                            <div class="table-inbox-wrap">
                                <table class="table table-inbox table-hover">
                                    <thead>
                                    <tr>
                                        <th style="width:120px;">序号</th>
                                        <th style="width:200px;">套餐名称</th>
                                        <th style="width:200px;">套餐内容</th>
                                        <th style="width:200px;">套餐优惠率 </th>
                                        <th style="width:200px;">保险状态</th>
                                        <@shiro.hasAnyRoles name="admin">
                                        <th style="width:200px;">审核</th>
                                        </@shiro.hasAnyRoles>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr v-for="(item,index) in result">
                                        <td>{{index+1}}</td>
                                        <td>{{item.combname}}</td>
                                        <td>
                                            <table style="width:400px">
                                                <tr class="active" v-for="(items,index) in item.list">
                                                    <td>{{items.insurname}}</td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td>
                                            {{item.combrate}}
                                          <#--  <span class="text-ellipsis">{{item.combrate}}</span>-->
                                        </td>
                                        <td>
                                            <span v-if="item.combstate==0" style="color:#f0ad4e;">待审核</span>
                                            <span v-if="item.combstate==1" style="color:#5bc0de">已上架</span>
                                            <span v-if="item.combstate==2" style="color:#428bca">审核未通过</span>
                                            <span v-if="item.combstate==3" style="color:#d9534f">已下架</span>
                                        </td>
                                        <@shiro.hasAnyRoles name="admin">
                                        <td><a href='#' @click="checkEvent(item.comuuid,item.combstate)" id="a" style="color: green">审核</a></td>
                                        </@shiro.hasAnyRoles>
                                    </tr>
                                    <tr>
                                        <td colspan="7" align="center">
                                            <div id="pageNav"></div>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </section>
    <#include "foot.ftl"><#--引入底部-->
    </section>
</section>
</body>
<#------>
</html>
<script>

    var app = new Vue({
        el: "#app",
        data: {
            result: []
        }
    });
    var getComboList = function (curr){
        $.ajax({
            url: "/comb/toGetComb",
            type: "post",
            dataType: "json",
            data: {
                pageSize: 5,
                pageNum: curr || 1,
                keyword: $("#keyword").val()
            },
            success: function (data) {
                app.result = data.page;

                laypage({
                    cont: 'pageNav',  //分页容器
                    pages: data.totalPage, //总页数
                    skin: '#336699',
                    first: '第一页',
                    last: '最后一页',
                    curr: curr || 1,
                    jump: function(obj, first){
                        if (!first) {
                            getComboList(obj.curr);
                        }
                    }
                });
            }
        });
    };
    getComboList();
    $("#keyword").keyup(function (){
        getComboList();
    });

    var checkEvent=function (comuuid,comstate) {
        if(comstate==1||comstate==2){
            layer.msg("已经审核过了",{icon:2});
            return;
            /*alert(caseState)*/
        }
        layer.confirm('是否通过？',{
                    btn:['通过','不通过','取消']
                },function () {
                    $.ajax({
                        type:'POST',
                        url:'/check/adoptCombo',
                        /* dataType:'json',后台往前台返回的类型是map的时候再用，如果是string的话，用就出错*/
                        data:{
                            comuuid:comuuid
                        },
                        success:function (msg) {
                            layer.msg('审核通过',{icon:6});
                            getComboList();
                        }
                    });
                },function () {
                    $.ajax({
                        type:'POST',
                        url:'/check/refuseCombo',
                        data:{
                            comuuid:comuuid
                        },
                        success:function (msg) {
                            layer.msg('审核不通过',{icon:5});
                            getComboList();
                        }
                    });
                },function () {

                }
        );
    }

</script>